package com.biqee.dao.base;

import java.util.HashMap;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.biqee.dao.BaseDAO;
import com.biqee.model.common.PageInfoObject;
import com.biqee.util.MapUtil;

public abstract class BaseDAOImpl extends SqlMapClientDaoSupport implements BaseDAO {
	protected  String namespace;
	
	@Override
	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}	
	
	protected String getRealSqlId(String sqlId) {
		return namespace + "." + sqlId;	
	}
	
	
	/**
	 * 将page对象属性与内置参数params都转换为map 条件
	 * @param page
	 * @return
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	protected Map<Object,Object> toMapCondition(PageInfoObject page){
		Map<Object,Object> condition  = MapUtil.populateMap(new HashMap(), page);
		if(page.getParams()!=null){
			condition.putAll(page.getParams());
		}
		return condition ;
		
	}
}